package cn.com.note.fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import cn.com.note.R;

/**
 * Created by SunFuLin on 2019/2/22.
 */

public class FragmentTest extends Fragment {
    private Context context;
    public static FragmentTest newInstance(String tag) {

        FragmentTest  fragment = new FragmentTest();
        Bundle args = new Bundle();
        args.putString("tag", tag);
        fragment.setArguments(args);
        return fragment;
    }
    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.context=getContext();
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.fragment_test,container,false);
        initView(view);
        return view;
    }

    private void initView(View view) {
        String tag=getArguments().getString("tag");
        TextView textView=view.findViewById(R.id.tv);
        textView.setText(tag);
    }
}
